//
//  STLogsDetailsController.swift
//  SlowTrajectory
//
//  Created by iOS-Czz on 2023/10/23.
//

import UIKit

class STLogsDetailsController: STProjectBaseController {
    lazy var deleteView: STDeleteTipView = {
        let view = Bundle.main.loadNibNamed("STDeleteTipView", owner: self, options: nil)?.first as! STDeleteTipView
        view.frame = keyWindow!.frame
        return view
    }()
    @IBOutlet var dayLabel: UILabel!
    @IBOutlet var contentTV: UITextView!
    @IBOutlet var thoughtsTV: UITextView!
    @IBOutlet var picture: UIImageView!
    var model: STLogsModel?
    override func viewDidLoad() {
        super.viewDidLoad()
        setNavStyle()
        setPageData()
        // Do any additional setup after loading the view.
    }
    func setPageData(){
        self.contentTV.text = self.model?.log
        self.picture.image = UIImage.loadImage(model!.picture)
        self.dayLabel.text = model!.day + model!.weekday
        self.thoughtsTV.text = model?.idea
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: true)
    }
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        self.picture.addDashedBorder(color: .black, lineWidth: 1, cornerRadius: 25)
    }
    func setNavStyle(){
        self.title = "日志详情"
        self.addRightBarButton(imageName: "icon_delete")
    }
    override func clockRightBarButtonAction() {
        self.deleteView.onSave = {
            self.model?.deleteToDB()
            self.navigationController?.popViewController(animated: true)
        }
        keyWindow!.addSubview(self.deleteView)
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
